package com.unitech.drink.converter;

import com.unitech.drink.api.beans.DrinkInfo;
import com.unitech.drink.api.enums.CategoryType;
import com.unitech.drink.dao.entity.Drink;

/**
 * 用于数据库实体类Drink的转换
 */
public class DrinkConverter {

    // 转换为DrinkInfo response对象
    public static DrinkInfo convertToDrinkInfo(Drink entity) {
        return DrinkInfo.builder()
                .id(entity.getId())
                .name(entity.getName())
                .price(entity.getPrice())
                .category(CategoryType.convert(entity.getCategoryId()).getDescription())
                .createTime(entity.getCreateTime())
                .imageUrl(entity.getImageUrl())
                .build();
    }
}
